home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AppsToGo / DTS.Draw / App.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  7.6 KB  |  316 lines  |  [TEXT/MPS ]

  1. #ifndef __APPHEADER__
  2. #define __APPHEADER__
  3.  
  4. #ifndef __DTSLib__
  5. #include "DTS.Lib.h"
  6. #endif
  7.  
  8. #ifndef __PRINTING__
  9. #include <Printing.h>
  10. #endif
  11.  
  12. #ifndef __TREEOBJ__
  13. #include <TreeObj.h>
  14. #endif
  15.  
  16. /********/
  17.  
  18. #define VH_VERSION  1                /* True means to include ViewHierarchy window.             */
  19. #define DEV_VERSION 1                /* True means allow option-cmd.period escape from dialogs. */
  20.  
  21. /* If you are unfamiliar with programming with the DTS.framework, you probably want to
  22. ** read the file "=How to write your app", which is found at the same level as the
  23. ** directory for this project. */
  24.  
  25. #ifdef powerc
  26. #pragma options align=mac68k
  27. #endif
  28. typedef struct {
  29.     DocHeaderInfo    fhInfo;        /* Doc header info (version, print record, window loc. ) */
  30.     TreeObjHndl        root;
  31.                                 /***** Start of custom file info. *****/
  32. } TheDoc;
  33. #ifdef powerc
  34. #pragma options align=reset
  35. #endif
  36.  
  37. /* Below is the master document structure.  All DTS.framework documents use this structure.
  38. ** For each unique document type, union in a sub-structure for the document-specific
  39. ** information.  In the case of DTS.Chat, there is only one document type.  The structure for
  40. ** this document type is defined just above.  Even though there is only one, it is still
  41. ** placed in a union.  This allows easy addition of additional document types later.
  42. ** Given a FileRec handle called frHndl, a sample dereference to the inBox field would look like:
  43. **     inBox = (*frHndl)->d.doc.inBox;
  44. **
  45. ** The fileState and connect fields are expected and managed by DTS.framework.  Also, the
  46. ** first two fields in the app-specific portion of the document are expected, namely
  47. ** the fhInfo and root fields. */
  48.  
  49. #ifdef powerc
  50. #pragma options align=mac68k
  51. #endif
  52. typedef struct FileRec {
  53.     FileStateRec    fileState;        /* DTS.Lib expects this structure here. */
  54.     ConnectRec        connect;        /* DTS.Lib expects this structure here. */
  55.     union {
  56.         TheDoc    doc;                /* Union in each document type here. */
  57.     } d;
  58. } FileRec;
  59. #ifdef powerc
  60. #pragma options align=reset
  61. #endif
  62.  
  63. /* Below is the definition of the hierarchical document's root object.  If you are using
  64. ** the hierarchical document package TreeObj, then you will need at least this object.
  65. ** TreeObj expects the first two fields to be undo and frHndl, as shown below.  You can
  66. ** add fields after these two fields.  If you use TreeObj, the root object and all of its
  67. ** children are automatically saved and read from disk.
  68. ** Note that the definition for the root object includes a prototype.  Each object is
  69. ** automatically called by DTS.LIB..framework at appropriate times.  The prototype defines the
  70. ** function that will be called for this object.  See the files "=How to write your app"
  71. ** and "=Using TreeObj.c" for more information. */
  72.  
  73. #ifdef powerc
  74. #pragma options align=mac68k
  75. #endif
  76. long    TRootObj(TreeObjHndl hndl, short message, long data);
  77. typedef struct {
  78.     TreeObjHndl    undo;        /* This structure may be added to, but */
  79.     FileRecHndl    frHndl;        /* these two first fields must remain. */
  80.     short        numSelected;
  81. } RootObj;
  82. typedef struct {
  83.     TreeObj    header;
  84.     RootObj    data;
  85. } RootObjPeek;
  86. #ifdef powerc
  87. #pragma options align=reset
  88. #endif
  89.  
  90. /* This definition allows us to access the fields that are in common between the below objects. */
  91.  
  92. #ifdef powerc
  93. #pragma options align=mac68k
  94. #endif
  95. typedef struct {
  96.     Boolean        selected;
  97.     Rect        rect;
  98.     short        penHeight;
  99.     short        penWidth;
  100.     RGBColor    borderColor;
  101.     Boolean        content;
  102.     RGBColor    contentColor;
  103. } CommonObj;
  104. typedef struct {
  105.     TreeObj        header;
  106.     CommonObj    data;
  107. } CommonObjPeek;
  108. #ifdef powerc
  109. #pragma options align=reset
  110. #endif
  111.  
  112.  
  113. /* Below are the definitions of the various DTS.Draw tool palette objects. */
  114.  
  115. #ifdef powerc
  116. #pragma options align=mac68k
  117. #endif
  118. long    TRectObj(TreeObjHndl hndl, short message, long data);
  119. typedef struct {
  120.     Boolean        selected;
  121.     Rect        rect;
  122.     short        penHeight;
  123.     short        penWidth;
  124.     RGBColor    borderColor;
  125.     Boolean        content;
  126.     RGBColor    contentColor;
  127. } RectObj;
  128. typedef struct {
  129.     TreeObj    header;
  130.     RectObj    data;
  131. } RectObjPeek;
  132. #ifdef powerc
  133. #pragma options align=reset
  134. #endif
  135.  
  136.  
  137. #ifdef powerc
  138. #pragma options align=mac68k
  139. #endif
  140. long    TRRectObj(TreeObjHndl hndl, short message, long data);
  141. typedef struct {
  142.     Boolean        selected;
  143.     Rect        rect;
  144.     short        penHeight;
  145.     short        penWidth;
  146.     RGBColor    borderColor;
  147.     Boolean        content;
  148.     RGBColor    contentColor;
  149.     short        width, height;
  150. } RRectObj;
  151. typedef struct {
  152.     TreeObj        header;
  153.     RRectObj    data;
  154. } RRectObjPeek;
  155. #ifdef powerc
  156. #pragma options align=reset
  157. #endif
  158.  
  159.  
  160. #ifdef powerc
  161. #pragma options align=mac68k
  162. #endif
  163. long    TOvalObj(TreeObjHndl hndl, short message, long data);
  164. typedef struct {
  165.     Boolean        selected;
  166.     Rect        oval;
  167.     short        penHeight;
  168.     short        penWidth;
  169.     RGBColor    borderColor;
  170.     Boolean        content;
  171.     RGBColor    contentColor;
  172. } OvalObj;
  173. typedef struct {
  174.     TreeObj    header;
  175.     OvalObj    data;
  176. } OvalObjPeek;
  177. #ifdef powerc
  178. #pragma options align=reset
  179. #endif
  180.  
  181.  
  182. #ifdef powerc
  183. #pragma options align=mac68k
  184. #endif
  185. OSErr    CalcPiePoints(TreeObjHndl hndl);
  186. long    TPieObj(TreeObjHndl hndl, short message, long data);
  187. typedef struct {
  188.     Boolean        selected;
  189.     Rect        arc;
  190.     short        penHeight;
  191.     short        penWidth;
  192.     RGBColor    borderColor;
  193.     Boolean        content;
  194.     RGBColor    contentColor;
  195.     short        arcStart;
  196.     short        arcLength;
  197.     Point        center;
  198.     Point        arcBegin;
  199.     Point        arcEnd;
  200. } PieObj;
  201. typedef struct {
  202.     TreeObj    header;
  203.     PieObj    data;
  204. } PieObjPeek;
  205. #ifdef powerc
  206. #pragma options align=reset
  207. #endif
  208.  
  209.  
  210. #ifdef powerc
  211. #pragma options align=mac68k
  212. #endif
  213. long    TLineObj(TreeObjHndl hndl, short message, long data);
  214. typedef struct {
  215.     Boolean        selected;
  216.     Rect        rect;
  217.     short        penHeight;
  218.     short        penWidth;
  219.     RGBColor    borderColor;
  220.     Boolean        content;
  221.     RGBColor    contentColor;
  222.     short        flip;
  223. } LineObj;
  224. typedef struct {
  225.     TreeObj    header;
  226.     LineObj    data;
  227. } LineObjPeek;
  228. #ifdef powerc
  229. #pragma options align=reset
  230. #endif
  231.  
  232.  
  233. #ifdef powerc
  234. #pragma options align=mac68k
  235. #endif
  236. long    TGroupObj(TreeObjHndl hndl, short message, long data);
  237. typedef struct {
  238.     Boolean    selected;
  239.     Rect    group;
  240. } GroupObj;
  241. typedef struct {
  242.     TreeObj        header;
  243.     GroupObj    data;
  244. } GroupObjPeek;
  245. #ifdef powerc
  246. #pragma options align=reset
  247. #endif
  248.  
  249.  
  250. #ifdef powerc
  251. #pragma options align=mac68k
  252. #endif
  253. long    TExtSelectObj(TreeObjHndl hndl, short message, long data);
  254. typedef struct {
  255.     Boolean    selected;
  256.     Rect    selectArea;
  257. } ExtSelectObj;
  258. typedef struct {
  259.     TreeObj            header;
  260.     ExtSelectObj    data;
  261. } ExtSelectObjPeek;
  262. #ifdef powerc
  263. #pragma options align=reset
  264. #endif
  265.  
  266.  
  267. #define VFLIPOBJ 0x01
  268. #define HFLIPOBJ 0x02
  269.  
  270.  
  271. /* Here are some macro definitions to make dereferencing document objects easier. */
  272.  
  273. #define mDerefRoot(hndl)      ((RootObj*)((*hndl) + 1))
  274. #define mDerefCommon(hndl)    ((CommonObj*)((*hndl) + 1))
  275. #define mDerefRect(hndl)      ((RectObj*)((*hndl) + 1))
  276. #define mDerefRRect(hndl)     ((RRectObj*)((*hndl) + 1))
  277. #define mDerefOval(hndl)      ((OvalObj*)((*hndl) + 1))
  278. #define mDerefPie(hndl)       ((PieObj*)((*hndl) + 1))
  279. #define mDerefLine(hndl)      ((LineObj*)((*hndl) + 1))
  280. #define mDerefGroup(hndl)     ((GroupObj*)((*hndl) + 1))
  281. #define mDerefExtSelect(hndl) ((ExtSelectObj*)((*hndl) + 1))
  282.  
  283.  
  284. /********/
  285.  
  286. #define kMaxNumUndos    64
  287. #define kNumSaveUndos    8
  288.  
  289. #define RECTOBJ            16
  290. #define RRECTOBJ        17
  291. #define OVALOBJ            18
  292. #define PIEOBJ            19
  293. #define LINEOBJ            20
  294. #define GROUPOBJ        65
  295. #define EXTSELECTOBJ    66
  296.  
  297. #define kNumTreeObjs    67        /* Minimum number of objects is 16. */
  298.  
  299.  
  300. /********/
  301.  
  302. /* These values are passed to the DTS.LIB..framework function Initialize(). */
  303. #define kMinHeap    64 * 1024        /* Needs at least 64k of heap space. */
  304. #define kMinSpace    64 * 1024        /* Needs this much after calling PurgeSpace. */
  305.  
  306.  
  307. #define kwAppWindow    (kwGrowIcon | kwHScrollLessGrow | kwVScrollLessGrow | kwVisible | kwOpenAtOldLoc)
  308.  
  309. #define kVersion        101        /* Document versions, not application versions. */
  310. #define kMinVersion        100
  311. #define kMaxVersion        101
  312.  
  313. #define kMaxNumWindows        65535        /* No limit on the number of windows. */
  314.  
  315. #endif
  316.